<extend name="Public/layout" />
<block name="body">
    <link rel="stylesheet" href="/Public/Wap/css/e.css">
    <link rel="stylesheet" href="/Public/Wap/css/plist.css">
    <script src="/Public/Wap/js/vue.js"></script>
    <script src="/Public/Wap/js/e.js"></script>
    <div id="app" class="panel panel-default panel-intro">
        <div class="panel-heading">
            <ul class="nav nav-tabs" data-field="warping">
                <li class="active"><a>商家列表</a></li>
            </ul>
        </div>
        <div class="panel-body">
            <div>
                <!-- <div class="title">
                    <img src="/Public/img/gz.png" alt=""> <span>商家列表</span>
                </div> -->
                <el-form :model="ruleForms" ref="ruleForms" label-width="100px" style="padding-top: 10px;" size="small">
                    <el-row class="item-topa top">
                        <el-col :span="5">
                            <el-form-item label="店铺">
                                <el-input v-model="ruleForms.seller_title"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="QQ">
                                <el-input v-model="ruleForms.qq"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="微信">
                                <el-input v-model="ruleForms.weixin_name"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="手机号码">
                                <el-input v-model="ruleForms.mobile"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="备注">
                                <el-input v-model="ruleForms.remark"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="员工">
                                <el-select v-model="ruleForms.mid" clearable placeholder="请选择" style="width:100%">
                                    <el-option v-for="item in userList" :key="item.uid" :label="item.nickname"
                                        :value="item.uid">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5"> &nbsp;&nbsp;&nbsp;&nbsp;<el-button type="primary" @click="onSubmit"
                                size="small">查询</el-button>
                            <el-button type="primary" @click="resetForma" size="small">清空</el-button>
                        </el-col>
                    </el-row>
                </el-form>
                <div style="padding: 10px 10px;" id="toolbar" class="toolbar">
                    <a @click="lists(1)" title="刷新" class="btn btn-primary btn-refresh">
                        <i class="fa fa-refresh"></i></a>
                </div>
                <div class="list">
                    <el-row class="item-top top">
                        <el-col :span="6"> 店铺信息 </el-col>
                        <el-col :span="3"> QQ </el-col>
                        <el-col :span="3"> 微信 </el-col>
                        <el-col :span="3"> 手机号码 </el-col>
                        <el-col :span="3"> 是否合作 </el-col>
                        <el-col :span="3"> 所有者 </el-col>
                        <el-col :span="3"> 操作 </el-col>
                    </el-row>
                    <el-row class="item" v-for="(i, index) in list" :key="index">
                        <el-col :span="6">
                            <div class="flex-start">
                                <div class="shop-info">
                                    <a :href="i.url" target="_blank" style="display: block;">
                                        <p class="shop-name"><img style="width: 15px;" src="/Public/img/jd.png"
                                                                  alt="">&nbsp;{{i.seller_title}}<img
                                                src="/Public/img/wangwang.png" alt="">
                                        </p>
                                    </a>
                                    <!-- <p class="website">地址：{{i.url}}</p> -->
                                </div>
                            </div>
                        </el-col>
                        <el-col :span="3"> {{i.qq}} </el-col>
                        <el-col :span="3"> {{i.weixin_name}} </el-col>
                        <el-col :span="3"> {{i.mobile}} </el-col>
                        <el-col :span="3"> 是 </el-col>
                        <el-col :span="3">
                            <!--<p class="code-id">账号：{{i.shopId}}</p>-->
                            <p>{{i.m_nickname}}</p>
                        </el-col>
                        <el-col :span="3">
                            <ul class="btns">
                                <!-- <li>店铺信息</li>
                        <li>立即推广</li> -->
                                <li @click="dialogVisible_btn(i.id)">预估效果</li>
                                <li @click='dialogVisible_form_btn(i.id)'>编辑</li>
                                <!-- <li @click='dialogVisible_hb_btn(i.id)'>换绑</li> -->
                                <!-- <li class="remove">删除</li> -->
                            </ul>
                        </el-col>
                    </el-row>
                    <el-dialog :visible.sync="dialogVisible" width="60%">
                        <div class="lg-title">预估效果</div>
                        <el-row class="lg-top">
                            <el-col :span="12">
                                <p>订单数</p>
                                <p>{{yuguxiaoguo.total_order_num}}</p>
                            </el-col>
                            <el-col :span="12">
                                <p>服务费</p>
                                <p>{{yuguxiaoguo.total_yugu_money}}</p>
                            </el-col>
                        </el-row>
                        <el-row class="lg-num">
                            <el-col :span="4">今日订单数</el-col>
                            <el-col :span="4">今日预估服务费</el-col>
                            <el-col :span="4">昨日订单数</el-col>
                            <el-col :span="4">昨日预估服务费</el-col>
                            <el-col :span="4">近7日订单数</el-col>
                            <el-col :span="4">近7日预估服务费</el-col>
                        </el-row>
                        <el-row class="lg-foot">
                            <el-col :span="4">{{yuguxiaoguo.today_order_num}}</el-col>
                            <el-col :span="4">{{yuguxiaoguo.today_yugu_money}}</el-col>
                            <el-col :span="4">{{yuguxiaoguo.yes_order_num}}</el-col>
                            <el-col :span="4">{{yuguxiaoguo.yes_yugu_money}}</el-col>
                            <el-col :span="4">{{yuguxiaoguo.qi_order_num}}</el-col>
                            <el-col :span="4">{{yuguxiaoguo.qi_yugu_money}}</el-col>
                        </el-row>
                    </el-dialog>
                    <el-dialog :visible.sync="dialogVisible_form" width="60%">
                        <div class="lg-title">编辑</div>
                        <div class="form-con">
                            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px"
                                class="demo-ruleForm">
                                <el-form-item label="店铺名称：" prop="seller_title">
                                    <el-input v-model="ruleForm.seller_title"></el-input>
                                </el-form-item>
                                <el-form-item label="店主昵称：" prop="seller_nickname">
                                    <el-input v-model="ruleForm.seller_nickname"></el-input>
                                </el-form-item>
                                <el-form-item label="店铺地址：" prop="url">
                                    <el-input v-model="ruleForm.url"></el-input>
                                </el-form-item>
                                <el-form-item label="微信：" prop="weixin_name">
                                    <el-input v-model="ruleForm.weixin_name"></el-input>
                                </el-form-item>
                                <el-form-item label="QQ：" prop="qq">
                                    <el-input v-model="ruleForm.qq"></el-input>
                                </el-form-item>
                                <el-form-item label="是否合作：" prop="is_hezuo">
                                    <el-radio-group v-model="ruleForm.is_hezuo">
                                        <el-radio label="1">是</el-radio>
                                        <el-radio label="0">否</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <div class="btnf">
                                    <el-button type="primary" @click="submitForm_bj('ruleForm')">确定</el-button>
                                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                                </div>
                            </el-form>
                        </div>
                    </el-dialog>
                    <el-dialog :visible.sync="dialogVisible_hb" width="60%">
                        <div class="lg-title">换绑</div>
                        <div class="form-con">
                            <el-form :rules="rules" ref="ruleForm_bd" label-width="100px" class="demo-ruleForm">
                                <el-form-item label="绑定店主：">
                                    <el-select v-model="region" placeholder="请选择活动区域" style="width: 100%;">
                                        <el-option :label="item.nickname" :value="item.uid"
                                            v-for="(item, index) in region_list"></el-option>
                                    </el-select>
                                </el-form-item>
                                <div class="btnf">
                                    <el-button type="primary" @click="submitForm_bd">确定</el-button>
                                </div>
                            </el-form>
                        </div>
                    </el-dialog>
                </div>
                <div class="pages" style="padding-top: 20px;">
                    <p class="text fl">每页显示10条，共{{page_count}}条</p>
                    <div class="fr">
                        <el-pagination background :current-page.sync="currentPage3" @current-change='check'
                            layout="prev, pager, next" :total=page_count>
                        </el-pagination>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    pagesize: 10,
                    currentPage3: 1,
                    page_count: 0,
                    list: [],
                    ruleForm: {
                        seller_title: '',
                        seller_nickname: '',
                        url: '',
                        weixin_name: '',
                        qq: '',
                    },
                    userList: [],
                    dialogVisible: false,
                    dialogVisible_form: false,
                    dialogVisible_hb: false,
                    ruleForms: {
                        seller_title: '',
                        seller_nickname: '',
                        url: '',
                        weixin_name: '',
                        qq: '',
                        is_hezuo: '',
                        remark: '',
                        mid: ''
                    },
                    ruleForm_bj: {

                    },
                    region_list: [],
                    region: '',
                    rules: {
                        seller_title: [{
                            required: true,
                            message: '请输入店铺名称',
                            trigger: 'blur'
                        },],
                        seller_nickname: [{
                            required: true,
                            message: '请输入店主昵称',
                            trigger: 'blur'
                        },],
                        url: [{
                            required: true,
                            message: '请输入店铺地址',
                            trigger: 'blur'
                        },],
                        is_hezuo: [{
                            required: true,
                            message: '请选择是否合作',
                            trigger: 'change'
                        }],
                    },
                    mid: '', //卖家id
                    yuguxiaoguo: {},
                }
            },
            mounted() {
                this.lists()
                this.binderList()
                this.getUserList();
            },
            methods: {
                getUserList() {
                    let that = this;
                    $.post(`/kcadmin/Jd/binderList`, {}, res => {
                        that.userList = res.data;
                    })
                },
                // 预估效果
                dialogVisible_btn(e) {
                    this.dialogVisible = true
                    this.mid = e
                    $.post(`/kcadmin/Jd/yuguxiaoguo`, {
                        id: this.mid
                    }, res => {
                        this.yuguxiaoguo = res.data
                    })
                },
                // bianji 
                dialogVisible_form_btn(e) {
                    this.dialogVisible_form = true
                    this.mid = e
                    $.post(`/kcadmin/Jd/sellerDetail`, {
                        id: this.mid
                    }, res => {
                        this.ruleForm = res.data
                    })
                },
                // 换绑
                // dialogVisible_hb_btn(e) {
                //     this.dialogVisible_hb = true
                //     this.mid = e
                //     $.post(`/kcadmin/Jd/editSeller`, {id:e}, res => {
                //         console.log( res.data)
                //         // this.editSeller = res.data
                //     })
                // },
                submitForm_bj(formName) {
                    console.log(this.ruleForm)
                    let that = this
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            $.post(`/kcadmin/Jd/editSeller`, this.ruleForm, res => {
                                res.code == 1 ? that.$message({
                                    message: res.msg,
                                    type: 'success'
                                }) : that.$message
                                    .error(res.msg);
                                res.code == 1 && (that.dialogVisible_form = false)
                            })
                            console.log(this.$refs[formName], valid)
                        } else {
                            console.log('error submit!!');
                            return false;
                        }
                    });
                },
                // 换绑确定
                submitForm_bd(e) {
                    console.log(this.region)
                    if (!this.region) {
                        return
                    }
                    $.post(`/kcadmin/Jd/bindSeller`, {
                        id: this.mid,
                        mid: this.region
                    }, res => {

                    })
                },
                onSubmit() {
                    this.lists(1)
                },
                resetForma() {
                    this.ruleForms.id = ''
                },
                resetForm(formName) {
                    this.$refs[formName].resetFields();
                },
                check(i) {
                    console.log('222', i)
                    this.lists(i)
                },
                lists(page) {
                    let data = {
                        page_num: page,
                        page_size: 10,
                    };
                    let postData = Object.assign(data, this.ruleForms)
                    $.post(`/kcadmin/Jd/sellerList`, postData, res => {
                        this.list = res.data
                        this.page_count = parseInt(res.page_count)
                        console.log(res)
                    });
                },
                binderList() {
                    let data = {

                    }
                    $.post(`/kcadmin/Jd/binderList`, {}, res => {
                        this.region_list = res.data
                        console.log(this.region_list)
                    })
                },
                handleClose(done) {
                    this.$confirm('确认关闭？')
                        .then(_ => {
                            done();
                        })
                        .catch(_ => { });
                }
            },

        })
    </script>
    <style>
        .form-con {
            width: 86%;
            margin: 50px auto 0 auto;
        }

        .btnf {
            display: flex;
            justify-content: flex-end;
            padding-bottom: 36px;
        }

        .btnf button {
            width: 100px;
        }

        .el-dialog__body {
            padding: 30px 0 0 0;
        }

        .el-dialog {
            width: 100%;
        }

        .lg-num,
        .lg-foot {
            height: 80px;
            line-height: 80px;
            text-align: center;
        }

        .el-dialog__headerbtn .el-dialog__close {
            color: #fff;
        }

        .lg-foot {
            border-top: 1px solid #eee;
        }

        .lg-top {
            text-align: center;
            font-size: 14px;
            padding: 50px 0 22px 0;
            border-bottom: 1px solid #eee;
        }

        .lg-title {
            width: 100%;
            height: 65px;
            line-height: 65px;
            position: absolute;
            top: 0;
            left: 0;
            background: #4A90E2;
            text-indent: 25px;
            color: #fff;
            font-size: 18px;
        }

        .el-dialog__headerbtn {
            z-index: 9;
            color: #fff !important;
        }

        .content-wrapper .content-top {
            display: none;
        }

        .fl {
            float: left;
        }

        .fr {
            float: right;
        }

        li {
            list-style: none;
        }

        .title {
            line-height: 98px;
            font-weight: 800;
            font-size: 18px;
            margin: 0 40px;
            position: relative;
        }

        .item-top {
            line-height: 60px;
        }

        .title img {
            width: 22px;
            height: 22px;
            margin-top: 12px;
            margin-right: 16px;
            position: absolute;
            top: 26px;
            left: -26px;
        }

        .list {
            min-width: 1050px;
            /* margin: 0 40px;
            overflow-y: auto; */
            border: 1px solid #f3f3f3;
        }

        .list .item {
            /* height: 60px; */
            padding: 15px 10px;
            font-size: 14px;
            /* padding-top: 12px; */
            display: flex;
            justify-content: flex-start;
            align-items: center;
        }

        .list .item .logo {
            width: 120px;
            height: 120px;
            margin: 0 21px 0 12px;
        }

        .list .item p {
            margin: 0;
        }

        .shop-info .name {
            margin: 12px 0;
        }

        .shop-name {
            display: flex;
            color: #0c0c0c
        }

        .shop-name img {
            width: 20px;
            height: 20px;
            margin-left: 6px;
        }

        .list .top {
            font-size: 14px;
            /* font-weight: 800; */
            padding: 0 10px;
        }

        .list .item:nth-child(even) {
            background: #f9f9f9;
        }

        .code-id {
            margin-bottom: 12px;
        }

        .btns li {
            width: 46%;
            height: 25px;
            line-height: 25px;
            margin: 0 4% 0 0;
            color: #fff;
            background: #4A90E2;
            text-align: center;
            float: left;
            font-size: 12px;
        }

        .btns .remove {
            background: #FF7400;
        }

        .flex-start {
            display: flex;
            justify-content: flex-start;
        }
    </style>
</block>